package com.punai.dataanalysis.srlib.controller;

import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.domain.TreeBo;
import com.punai.common.core.page.TableDataInfo;
import com.punai.dataanalysis.srlib.bo.SrIndicatorBo;
import com.punai.dataanalysis.srlib.bo.SrIndicatorDetailBo;
import com.punai.dataanalysis.srlib.service.SrIndicatorService;
import com.punai.dataanalysis.srlib.vo.SrIndicatorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/srLib/srIndicator")
public class SrIndicatorController extends BaseController {

    @Autowired
    private SrIndicatorService srIndicatorService;

    /**
     * 模板与结构树
     * @return
     */
    @PreAuthorize("@ss.hasPermi('srlib:srIndicator:list')")
    @GetMapping("/templateStructTree")
    public AjaxResult templateStructTree() {
        List<TreeBo> treeBos = srIndicatorService.templateStructTree();
        return AjaxResult.success(treeBos);
    }

    @PreAuthorize("@ss.hasPermi('srlib:srIndicator:list')")
    @GetMapping("getIndicatorList")
    public AjaxResult getIndicatorList(SrIndicatorVo vo) {
        List<SrIndicatorBo> res = srIndicatorService.getIndicatorList(vo);
        return AjaxResult.success(res);
    }

    @PreAuthorize("@ss.hasPermi('srlib:srIndicator:detaillist')")
    @GetMapping("getStructIndicatorDetailList")
    public TableDataInfo getStructIndicatorDetailList(SrIndicatorVo vo) {
        startPage();
        List<SrIndicatorDetailBo> res = srIndicatorService.getStructIndicatorDetailList(vo);
        return getDataTable(res);
    }


}
